package com.aacar.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aacar.dto.Header;
import com.aacar.entity.WashCityDto;
import com.aacar.service.ThirdCommonService;
import com.aacar.utils.ErrorCodeConsField;
import com.aacar.utils.ErrorInfoUtil;
import com.aacar.utils.Pphconfig;
import com.aacar.utils.ResultInfoUtil;
import com.aacar.vo.WashIndexVo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * 天气工具类
 * @author wanghui
 *
 */
@RestController
@RequestMapping("/washCarIndex")
public class ThirdCommonController extends ValidController{
	
	@Autowired
	private  HttpServletRequest request; 
	
	@Autowired
	private ThirdCommonService thirdCommonService;
	
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	//获取洗车指数
	@RequestMapping("/getWashIndex/0")
	public Object getWashIndex(@RequestHeader(value="mobilehead") String mobilehead,@RequestBody WashCityDto washCityDto) {
		logger.info("request:/washCarIndex/getWashIndex/0" + JSONObject.toJSONString(washCityDto));
		Header header = null;
		if(null != mobilehead) {
			header = JSON.parseObject(mobilehead, Header.class);
		}
		WashIndexVo wrv = this.thirdCommonService.getWashResultVo(washCityDto);
		if(null == wrv) {
			wrv = new WashIndexVo();
			wrv.setHigh("25");
			wrv.setLow("18");
			wrv.setWashDetail("适合洗车");
			wrv.setCurrentTemperature("20");
			wrv.setWashIndex("适宜");
			wrv.setWealth("晴");
//			return ErrorInfoUtil.setErrorInfo(ErrorCodeConsField.ERROR_MSG_30008, Pphconfig.getContextProperty(ErrorCodeConsField.ERROR_MSG_30008),header.getService());
		}
		return ResultInfoUtil.setSuccessInfo(wrv,header.getService());
	}
	
}
